﻿
#region Using Directives

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    using MarketPulse.BusinessLogic.Common;

#endregion

namespace MarketPulse.BusinessLogic.Private.StateMachine
{
    [Serializable]
    internal class VisitStateDataEntryInProgress : VisitStateBase
    {
        internal VisitStateDataEntryInProgress(bool throwIfInvalid)
            : base(throwIfInvalid)
        {
            mVisitStateType = VisitStatusTypeList.DataEntryInProgress;
            InitVisitStateString();
        }

        public override bool StartDataEntry(IVisitStateContext context, bool tryTransition)
        {
            // Do nothing probably, but this is a valid transition
            return true;
        }

        public override bool DataEnter(IVisitStateContext context, bool tryTransition, System.Xml.Linq.XElement responses)
        {
            // Do nothing probably, but this is a valid transition
            return true;
        }

        public override bool CompleteDataEntry(IVisitStateContext context, bool tryTransition)
        {
            if (!tryTransition)
            {
                context.SetState(new VisitStateAwaitingQA(mThrowIfInvalid));
            }
            return true;
        }

        public override bool Unassign(IVisitStateContext context, bool tryTransition, Visit.PaymentStatus payment)
        {
            if (!tryTransition)
            {
                context.SetState(new VisitStateReleased(mThrowIfInvalid));
            }
            return true;
        }

        public override bool Revisit(IVisitStateContext context, bool tryTransition)
        {
            if (!tryTransition)
            {
                context.SetState(new VisitStateReleased(mThrowIfInvalid));
            }
            return true;
        }
    }
}
